module.exports = function ($scope, $state, $resource, $modal, type_list, enterpriseList, enterpriseType) {

	$scope.maxSize = '5';			//最多显示多少个按钮
    $scope.currentPage = '1';		//当前页码
	$scope.itemsPerPage = '20'		//每页显示几条
	$scope.search = {};
	$scope.no_pass = true;

	$scope.type_list = type_list;

	init();
	//初始化加载企业列表
	function init(item){
		$(".tabel_body").hide();
		var para = {
            'pageNo':$scope.currentPage,
            'pageSize':$scope.itemsPerPage
		};
		if(item){
			para.registration_type = item.type,
			para.no_pass = item.no_pass
		}
		enterpriseList.save(para, function (res) {
			if (res.errcode === 0) {
				$(".tabel_body").show();
				$scope.enterpriseList = res.data.results;
				$scope.totalItems = res.data.totalRecord;
			} else {
				alert(res.errmsg);
			}
		});
	}

	//搜索按钮
	$scope.searchType = function (){
		init($scope.search.type);
	};

	//查看未通过企业
	$scope.noPass = function (){
		init({'type': $scope.search.type.type, 'no_pass': '1'});
		$scope.no_pass = false;
	};

	//返回企业审核列表
	$scope.back = function (){
		init($scope.search.type);
		$scope.no_pass = true;
	};

	//审核企业信息
	$scope.check = function (item){
		var modalInstance = $modal.open({
			template: require('../views/enterprise_info.html'),
			controller: 'enterpriseInfo',
			size: 'lg',
			resolve: {
				item: function () {
					return item;
				},
				enterpriseType: function () {
					return enterpriseType;
				}
			}
		});
		modalInstance.result.then(function() {
			init();
		});
	};

	//查看未通过原因
	$scope.reason = function (item){
		var modalInstance = $modal.open({
			template: require('../views/enterprise_nopass.html'),
			controller: 'enterpriseNopass',
			size: 'lg',
			resolve: {
				para: function () {
					return item;
				},
				no_pass: function () {
					return $scope.no_pass;
				}
			}
		});
		modalInstance.result.then(function() {
			$modalInstance.close();
		});
	};

	//重新审核
	$scope.recheck = function (item){
		console.log(item);
	};

};